<?php if(!defined('GbIncl2')){ ?>
<meta http-equiv="refresh" content="0;url=../spm-itats/block.php" />
<?php }else{ ?>
<?php 
if (!empty($_FILES['logo']['name']) and $_FILES['logo']['size']>64000){
	echo "Ukuran File Maksimal 64kb";
	//echo $_FILES['logo']['type'];
	
}else if (!empty($_FILES['logo']['name']) and $_FILES['logo']['type']!='image/jpeg'){
	echo "Type File harus (.jpg)";
}
else if (!empty($_FILES['logo']['name']) and $_FILES['logo']['size']<64000 and $_FILES['logo']['type']=='image/jpeg'){
$file_name=$_FILES['logo']['name']; //nama file (tanpa path)
$tmp_name=$_FILES['logo']['tmp_name']; //nama local temp file di server
$file_size=$_FILES['logo']['size']; //ukuran file (dalam bytes)
$file_type=$_FILES['logo']['type']; //tipe filenya (langsung detect MIMEnya)
$fp=fopen($tmp_name,'r'); // open file (read-only, binary)
$file_content=fread($fp, $file_size) or die("Tidak dapat membaca source file"); // read file
$file_content=mysql_real_escape_string($file_content) or die("Tidak dapat membaca source file"); // parse image ke string
fclose($fp); // tuptup file

    /* query dan proses handling untuk melakukan insert ke database*/

$qu="UPDATE BERITA_SPM SET GAMBAR_BS='$file_content' WHERE ID_BS='BS-00000'";
$re=mysql_query($qu) or die ("Gagal UPDATE ke database");
$image_info = getimagesize($_FILES["logo"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];
//echo "width : $image_width - height : $image_height";
?><meta http-equiv="refresh" content="0;url=../cpanel?setting=logo" /><?php
}else {
	echo "Tidak ada File yang dipilih<br />";
}
?>
<?php
$query="select GAMBAR_BS from BERITA_SPM order by ID_BS desc limit 1";
$data=mysql_query($query);
$data=mysql_fetch_array($data);
$content=$data[0];
$type='image/jpeg';
echo '<img src="data:image/jpeg;base64,'.base64_encode($content).'" alt="photo"width="100%" ><br /><br />';
?>

                            <form action="" method="post" enctype="multipart/form-data">
                            	Pilih File : <input type="file" name="logo" /><input type="submit" value="Upload" />
                            </form>
                        <?php }?>
<?php
/*

*/
?>